package com.example.service;

import com.example.entity.Checkpoint;
import com.example.entity.CommonQuestion;
import com.example.mapper.CommonQuestionMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
常见问题业务处理
 */
@Service
public class CommonQuestionService {

    @Resource
    private CommonQuestionMapper commonQuestionMapper;

    public void add(CommonQuestion commonQuestion) {
        commonQuestionMapper.insert(commonQuestion);
    }

    public void deleteById(Integer id) {
        commonQuestionMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(CommonQuestion commonQuestion) {
        commonQuestionMapper.updateById(commonQuestion);
    }

    public CommonQuestion selectById(Integer id) {
        return commonQuestionMapper.selectById(id);
    }

    public List<CommonQuestion> selectAll(CommonQuestion commonQuestion) {
        return commonQuestionMapper.selectAll(commonQuestion);
    }

    public PageInfo<CommonQuestion> selectPage(CommonQuestion commonQuestion, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<CommonQuestion> commonQuestionList = commonQuestionMapper.selectAll(commonQuestion);
        return PageInfo.of(commonQuestionList);
    }
}
